{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "stopped-romania",
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "path='../../swin_conv/output/swin2conv_dw_bn_tiny_patch4_window7_224/swin2conv_dw_bn_tiny_patch4_window7_224/default/ckpt_epoch_295.pth'\n",
    "a=torch.load(path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "defined-blade",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/data/home/zejia/mycontainer2/swin_conv_det/mmdet'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "potential-criterion",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "odict_keys(['patch_embed.proj.weight', 'patch_embed.proj.bias', 'patch_embed.norm.weight', 'patch_embed.norm.bias', 'layers.0.blocks.0.attn2conv.conv0.weight', 'layers.0.blocks.0.attn2conv.bn0.weight', 'layers.0.blocks.0.attn2conv.bn0.bias', 'layers.0.blocks.0.attn2conv.bn0.running_mean', 'layers.0.blocks.0.attn2conv.bn0.running_var', 'layers.0.blocks.0.attn2conv.bn0.num_batches_tracked', 'layers.0.blocks.0.attn2conv.conv.weight', 'layers.0.blocks.0.attn2conv.conv.bias', 'layers.0.blocks.0.attn2conv.bn.weight', 'layers.0.blocks.0.attn2conv.bn.bias', 'layers.0.blocks.0.attn2conv.bn.running_mean', 'layers.0.blocks.0.attn2conv.bn.running_var', 'layers.0.blocks.0.attn2conv.bn.num_batches_tracked', 'layers.0.blocks.0.attn2conv.conv2.weight', 'layers.0.blocks.0.attn2conv.bn2.weight', 'layers.0.blocks.0.attn2conv.bn2.bias', 'layers.0.blocks.0.attn2conv.bn2.running_mean', 'layers.0.blocks.0.attn2conv.bn2.running_var', 'layers.0.blocks.0.attn2conv.bn2.num_batches_tracked', 'layers.0.blocks.0.mlp.fc1.weight', 'layers.0.blocks.0.mlp.fc1.bias', 'layers.0.blocks.0.mlp.fc2.weight', 'layers.0.blocks.0.mlp.fc2.bias', 'layers.0.blocks.0.bn.weight', 'layers.0.blocks.0.bn.bias', 'layers.0.blocks.0.bn.running_mean', 'layers.0.blocks.0.bn.running_var', 'layers.0.blocks.0.bn.num_batches_tracked', 'layers.0.blocks.1.attn2conv.conv0.weight', 'layers.0.blocks.1.attn2conv.bn0.weight', 'layers.0.blocks.1.attn2conv.bn0.bias', 'layers.0.blocks.1.attn2conv.bn0.running_mean', 'layers.0.blocks.1.attn2conv.bn0.running_var', 'layers.0.blocks.1.attn2conv.bn0.num_batches_tracked', 'layers.0.blocks.1.attn2conv.conv.weight', 'layers.0.blocks.1.attn2conv.conv.bias', 'layers.0.blocks.1.attn2conv.bn.weight', 'layers.0.blocks.1.attn2conv.bn.bias', 'layers.0.blocks.1.attn2conv.bn.running_mean', 'layers.0.blocks.1.attn2conv.bn.running_var', 'layers.0.blocks.1.attn2conv.bn.num_batches_tracked', 'layers.0.blocks.1.attn2conv.conv2.weight', 'layers.0.blocks.1.attn2conv.bn2.weight', 'layers.0.blocks.1.attn2conv.bn2.bias', 'layers.0.blocks.1.attn2conv.bn2.running_mean', 'layers.0.blocks.1.attn2conv.bn2.running_var', 'layers.0.blocks.1.attn2conv.bn2.num_batches_tracked', 'layers.0.blocks.1.mlp.fc1.weight', 'layers.0.blocks.1.mlp.fc1.bias', 'layers.0.blocks.1.mlp.fc2.weight', 'layers.0.blocks.1.mlp.fc2.bias', 'layers.0.blocks.1.bn.weight', 'layers.0.blocks.1.bn.bias', 'layers.0.blocks.1.bn.running_mean', 'layers.0.blocks.1.bn.running_var', 'layers.0.blocks.1.bn.num_batches_tracked', 'layers.0.downsample.reduction.weight', 'layers.0.downsample.norm.weight', 'layers.0.downsample.norm.bias', 'layers.1.blocks.0.attn2conv.conv0.weight', 'layers.1.blocks.0.attn2conv.bn0.weight', 'layers.1.blocks.0.attn2conv.bn0.bias', 'layers.1.blocks.0.attn2conv.bn0.running_mean', 'layers.1.blocks.0.attn2conv.bn0.running_var', 'layers.1.blocks.0.attn2conv.bn0.num_batches_tracked', 'layers.1.blocks.0.attn2conv.conv.weight', 'layers.1.blocks.0.attn2conv.conv.bias', 'layers.1.blocks.0.attn2conv.bn.weight', 'layers.1.blocks.0.attn2conv.bn.bias', 'layers.1.blocks.0.attn2conv.bn.running_mean', 'layers.1.blocks.0.attn2conv.bn.running_var', 'layers.1.blocks.0.attn2conv.bn.num_batches_tracked', 'layers.1.blocks.0.attn2conv.conv2.weight', 'layers.1.blocks.0.attn2conv.bn2.weight', 'layers.1.blocks.0.attn2conv.bn2.bias', 'layers.1.blocks.0.attn2conv.bn2.running_mean', 'layers.1.blocks.0.attn2conv.bn2.running_var', 'layers.1.blocks.0.attn2conv.bn2.num_batches_tracked', 'layers.1.blocks.0.mlp.fc1.weight', 'layers.1.blocks.0.mlp.fc1.bias', 'layers.1.blocks.0.mlp.fc2.weight', 'layers.1.blocks.0.mlp.fc2.bias', 'layers.1.blocks.0.bn.weight', 'layers.1.blocks.0.bn.bias', 'layers.1.blocks.0.bn.running_mean', 'layers.1.blocks.0.bn.running_var', 'layers.1.blocks.0.bn.num_batches_tracked', 'layers.1.blocks.1.attn2conv.conv0.weight', 'layers.1.blocks.1.attn2conv.bn0.weight', 'layers.1.blocks.1.attn2conv.bn0.bias', 'layers.1.blocks.1.attn2conv.bn0.running_mean', 'layers.1.blocks.1.attn2conv.bn0.running_var', 'layers.1.blocks.1.attn2conv.bn0.num_batches_tracked', 'layers.1.blocks.1.attn2conv.conv.weight', 'layers.1.blocks.1.attn2conv.conv.bias', 'layers.1.blocks.1.attn2conv.bn.weight', 'layers.1.blocks.1.attn2conv.bn.bias', 'layers.1.blocks.1.attn2conv.bn.running_mean', 'layers.1.blocks.1.attn2conv.bn.running_var', 'layers.1.blocks.1.attn2conv.bn.num_batches_tracked', 'layers.1.blocks.1.attn2conv.conv2.weight', 'layers.1.blocks.1.attn2conv.bn2.weight', 'layers.1.blocks.1.attn2conv.bn2.bias', 'layers.1.blocks.1.attn2conv.bn2.running_mean', 'layers.1.blocks.1.attn2conv.bn2.running_var', 'layers.1.blocks.1.attn2conv.bn2.num_batches_tracked', 'layers.1.blocks.1.mlp.fc1.weight', 'layers.1.blocks.1.mlp.fc1.bias', 'layers.1.blocks.1.mlp.fc2.weight', 'layers.1.blocks.1.mlp.fc2.bias', 'layers.1.blocks.1.bn.weight', 'layers.1.blocks.1.bn.bias', 'layers.1.blocks.1.bn.running_mean', 'layers.1.blocks.1.bn.running_var', 'layers.1.blocks.1.bn.num_batches_tracked', 'layers.1.downsample.reduction.weight', 'layers.1.downsample.norm.weight', 'layers.1.downsample.norm.bias', 'layers.2.blocks.0.attn2conv.conv0.weight', 'layers.2.blocks.0.attn2conv.bn0.weight', 'layers.2.blocks.0.attn2conv.bn0.bias', 'layers.2.blocks.0.attn2conv.bn0.running_mean', 'layers.2.blocks.0.attn2conv.bn0.running_var', 'layers.2.blocks.0.attn2conv.bn0.num_batches_tracked', 'layers.2.blocks.0.attn2conv.conv.weight', 'layers.2.blocks.0.attn2conv.conv.bias', 'layers.2.blocks.0.attn2conv.bn.weight', 'layers.2.blocks.0.attn2conv.bn.bias', 'layers.2.blocks.0.attn2conv.bn.running_mean', 'layers.2.blocks.0.attn2conv.bn.running_var', 'layers.2.blocks.0.attn2conv.bn.num_batches_tracked', 'layers.2.blocks.0.attn2conv.conv2.weight', 'layers.2.blocks.0.attn2conv.bn2.weight', 'layers.2.blocks.0.attn2conv.bn2.bias', 'layers.2.blocks.0.attn2conv.bn2.running_mean', 'layers.2.blocks.0.attn2conv.bn2.running_var', 'layers.2.blocks.0.attn2conv.bn2.num_batches_tracked', 'layers.2.blocks.0.mlp.fc1.weight', 'layers.2.blocks.0.mlp.fc1.bias', 'layers.2.blocks.0.mlp.fc2.weight', 'layers.2.blocks.0.mlp.fc2.bias', 'layers.2.blocks.0.bn.weight', 'layers.2.blocks.0.bn.bias', 'layers.2.blocks.0.bn.running_mean', 'layers.2.blocks.0.bn.running_var', 'layers.2.blocks.0.bn.num_batches_tracked', 'layers.2.blocks.1.attn2conv.conv0.weight', 'layers.2.blocks.1.attn2conv.bn0.weight', 'layers.2.blocks.1.attn2conv.bn0.bias', 'layers.2.blocks.1.attn2conv.bn0.running_mean', 'layers.2.blocks.1.attn2conv.bn0.running_var', 'layers.2.blocks.1.attn2conv.bn0.num_batches_tracked', 'layers.2.blocks.1.attn2conv.conv.weight', 'layers.2.blocks.1.attn2conv.conv.bias', 'layers.2.blocks.1.attn2conv.bn.weight', 'layers.2.blocks.1.attn2conv.bn.bias', 'layers.2.blocks.1.attn2conv.bn.running_mean', 'layers.2.blocks.1.attn2conv.bn.running_var', 'layers.2.blocks.1.attn2conv.bn.num_batches_tracked', 'layers.2.blocks.1.attn2conv.conv2.weight', 'layers.2.blocks.1.attn2conv.bn2.weight', 'layers.2.blocks.1.attn2conv.bn2.bias', 'layers.2.blocks.1.attn2conv.bn2.running_mean', 'layers.2.blocks.1.attn2conv.bn2.running_var', 'layers.2.blocks.1.attn2conv.bn2.num_batches_tracked', 'layers.2.blocks.1.mlp.fc1.weight', 'layers.2.blocks.1.mlp.fc1.bias', 'layers.2.blocks.1.mlp.fc2.weight', 'layers.2.blocks.1.mlp.fc2.bias', 'layers.2.blocks.1.bn.weight', 'layers.2.blocks.1.bn.bias', 'layers.2.blocks.1.bn.running_mean', 'layers.2.blocks.1.bn.running_var', 'layers.2.blocks.1.bn.num_batches_tracked', 'layers.2.blocks.2.attn2conv.conv0.weight', 'layers.2.blocks.2.attn2conv.bn0.weight', 'layers.2.blocks.2.attn2conv.bn0.bias', 'layers.2.blocks.2.attn2conv.bn0.running_mean', 'layers.2.blocks.2.attn2conv.bn0.running_var', 'layers.2.blocks.2.attn2conv.bn0.num_batches_tracked', 'layers.2.blocks.2.attn2conv.conv.weight', 'layers.2.blocks.2.attn2conv.conv.bias', 'layers.2.blocks.2.attn2conv.bn.weight', 'layers.2.blocks.2.attn2conv.bn.bias', 'layers.2.blocks.2.attn2conv.bn.running_mean', 'layers.2.blocks.2.attn2conv.bn.running_var', 'layers.2.blocks.2.attn2conv.bn.num_batches_tracked', 'layers.2.blocks.2.attn2conv.conv2.weight', 'layers.2.blocks.2.attn2conv.bn2.weight', 'layers.2.blocks.2.attn2conv.bn2.bias', 'layers.2.blocks.2.attn2conv.bn2.running_mean', 'layers.2.blocks.2.attn2conv.bn2.running_var', 'layers.2.blocks.2.attn2conv.bn2.num_batches_tracked', 'layers.2.blocks.2.mlp.fc1.weight', 'layers.2.blocks.2.mlp.fc1.bias', 'layers.2.blocks.2.mlp.fc2.weight', 'layers.2.blocks.2.mlp.fc2.bias', 'layers.2.blocks.2.bn.weight', 'layers.2.blocks.2.bn.bias', 'layers.2.blocks.2.bn.running_mean', 'layers.2.blocks.2.bn.running_var', 'layers.2.blocks.2.bn.num_batches_tracked', 'layers.2.blocks.3.attn2conv.conv0.weight', 'layers.2.blocks.3.attn2conv.bn0.weight', 'layers.2.blocks.3.attn2conv.bn0.bias', 'layers.2.blocks.3.attn2conv.bn0.running_mean', 'layers.2.blocks.3.attn2conv.bn0.running_var', 'layers.2.blocks.3.attn2conv.bn0.num_batches_tracked', 'layers.2.blocks.3.attn2conv.conv.weight', 'layers.2.blocks.3.attn2conv.conv.bias', 'layers.2.blocks.3.attn2conv.bn.weight', 'layers.2.blocks.3.attn2conv.bn.bias', 'layers.2.blocks.3.attn2conv.bn.running_mean', 'layers.2.blocks.3.attn2conv.bn.running_var', 'layers.2.blocks.3.attn2conv.bn.num_batches_tracked', 'layers.2.blocks.3.attn2conv.conv2.weight', 'layers.2.blocks.3.attn2conv.bn2.weight', 'layers.2.blocks.3.attn2conv.bn2.bias', 'layers.2.blocks.3.attn2conv.bn2.running_mean', 'layers.2.blocks.3.attn2conv.bn2.running_var', 'layers.2.blocks.3.attn2conv.bn2.num_batches_tracked', 'layers.2.blocks.3.mlp.fc1.weight', 'layers.2.blocks.3.mlp.fc1.bias', 'layers.2.blocks.3.mlp.fc2.weight', 'layers.2.blocks.3.mlp.fc2.bias', 'layers.2.blocks.3.bn.weight', 'layers.2.blocks.3.bn.bias', 'layers.2.blocks.3.bn.running_mean', 'layers.2.blocks.3.bn.running_var', 'layers.2.blocks.3.bn.num_batches_tracked', 'layers.2.blocks.4.attn2conv.conv0.weight', 'layers.2.blocks.4.attn2conv.bn0.weight', 'layers.2.blocks.4.attn2conv.bn0.bias', 'layers.2.blocks.4.attn2conv.bn0.running_mean', 'layers.2.blocks.4.attn2conv.bn0.running_var', 'layers.2.blocks.4.attn2conv.bn0.num_batches_tracked', 'layers.2.blocks.4.attn2conv.conv.weight', 'layers.2.blocks.4.attn2conv.conv.bias', 'layers.2.blocks.4.attn2conv.bn.weight', 'layers.2.blocks.4.attn2conv.bn.bias', 'layers.2.blocks.4.attn2conv.bn.running_mean', 'layers.2.blocks.4.attn2conv.bn.running_var', 'layers.2.blocks.4.attn2conv.bn.num_batches_tracked', 'layers.2.blocks.4.attn2conv.conv2.weight', 'layers.2.blocks.4.attn2conv.bn2.weight', 'layers.2.blocks.4.attn2conv.bn2.bias', 'layers.2.blocks.4.attn2conv.bn2.running_mean', 'layers.2.blocks.4.attn2conv.bn2.running_var', 'layers.2.blocks.4.attn2conv.bn2.num_batches_tracked', 'layers.2.blocks.4.mlp.fc1.weight', 'layers.2.blocks.4.mlp.fc1.bias', 'layers.2.blocks.4.mlp.fc2.weight', 'layers.2.blocks.4.mlp.fc2.bias', 'layers.2.blocks.4.bn.weight', 'layers.2.blocks.4.bn.bias', 'layers.2.blocks.4.bn.running_mean', 'layers.2.blocks.4.bn.running_var', 'layers.2.blocks.4.bn.num_batches_tracked', 'layers.2.blocks.5.attn2conv.conv0.weight', 'layers.2.blocks.5.attn2conv.bn0.weight', 'layers.2.blocks.5.attn2conv.bn0.bias', 'layers.2.blocks.5.attn2conv.bn0.running_mean', 'layers.2.blocks.5.attn2conv.bn0.running_var', 'layers.2.blocks.5.attn2conv.bn0.num_batches_tracked', 'layers.2.blocks.5.attn2conv.conv.weight', 'layers.2.blocks.5.attn2conv.conv.bias', 'layers.2.blocks.5.attn2conv.bn.weight', 'layers.2.blocks.5.attn2conv.bn.bias', 'layers.2.blocks.5.attn2conv.bn.running_mean', 'layers.2.blocks.5.attn2conv.bn.running_var', 'layers.2.blocks.5.attn2conv.bn.num_batches_tracked', 'layers.2.blocks.5.attn2conv.conv2.weight', 'layers.2.blocks.5.attn2conv.bn2.weight', 'layers.2.blocks.5.attn2conv.bn2.bias', 'layers.2.blocks.5.attn2conv.bn2.running_mean', 'layers.2.blocks.5.attn2conv.bn2.running_var', 'layers.2.blocks.5.attn2conv.bn2.num_batches_tracked', 'layers.2.blocks.5.mlp.fc1.weight', 'layers.2.blocks.5.mlp.fc1.bias', 'layers.2.blocks.5.mlp.fc2.weight', 'layers.2.blocks.5.mlp.fc2.bias', 'layers.2.blocks.5.bn.weight', 'layers.2.blocks.5.bn.bias', 'layers.2.blocks.5.bn.running_mean', 'layers.2.blocks.5.bn.running_var', 'layers.2.blocks.5.bn.num_batches_tracked', 'layers.2.downsample.reduction.weight', 'layers.2.downsample.norm.weight', 'layers.2.downsample.norm.bias', 'layers.3.blocks.0.attn2conv.conv0.weight', 'layers.3.blocks.0.attn2conv.bn0.weight', 'layers.3.blocks.0.attn2conv.bn0.bias', 'layers.3.blocks.0.attn2conv.bn0.running_mean', 'layers.3.blocks.0.attn2conv.bn0.running_var', 'layers.3.blocks.0.attn2conv.bn0.num_batches_tracked', 'layers.3.blocks.0.attn2conv.conv.weight', 'layers.3.blocks.0.attn2conv.conv.bias', 'layers.3.blocks.0.attn2conv.bn.weight', 'layers.3.blocks.0.attn2conv.bn.bias', 'layers.3.blocks.0.attn2conv.bn.running_mean', 'layers.3.blocks.0.attn2conv.bn.running_var', 'layers.3.blocks.0.attn2conv.bn.num_batches_tracked', 'layers.3.blocks.0.attn2conv.conv2.weight', 'layers.3.blocks.0.attn2conv.bn2.weight', 'layers.3.blocks.0.attn2conv.bn2.bias', 'layers.3.blocks.0.attn2conv.bn2.running_mean', 'layers.3.blocks.0.attn2conv.bn2.running_var', 'layers.3.blocks.0.attn2conv.bn2.num_batches_tracked', 'layers.3.blocks.0.mlp.fc1.weight', 'layers.3.blocks.0.mlp.fc1.bias', 'layers.3.blocks.0.mlp.fc2.weight', 'layers.3.blocks.0.mlp.fc2.bias', 'layers.3.blocks.0.bn.weight', 'layers.3.blocks.0.bn.bias', 'layers.3.blocks.0.bn.running_mean', 'layers.3.blocks.0.bn.running_var', 'layers.3.blocks.0.bn.num_batches_tracked', 'layers.3.blocks.1.attn2conv.conv0.weight', 'layers.3.blocks.1.attn2conv.bn0.weight', 'layers.3.blocks.1.attn2conv.bn0.bias', 'layers.3.blocks.1.attn2conv.bn0.running_mean', 'layers.3.blocks.1.attn2conv.bn0.running_var', 'layers.3.blocks.1.attn2conv.bn0.num_batches_tracked', 'layers.3.blocks.1.attn2conv.conv.weight', 'layers.3.blocks.1.attn2conv.conv.bias', 'layers.3.blocks.1.attn2conv.bn.weight', 'layers.3.blocks.1.attn2conv.bn.bias', 'layers.3.blocks.1.attn2conv.bn.running_mean', 'layers.3.blocks.1.attn2conv.bn.running_var', 'layers.3.blocks.1.attn2conv.bn.num_batches_tracked', 'layers.3.blocks.1.attn2conv.conv2.weight', 'layers.3.blocks.1.attn2conv.bn2.weight', 'layers.3.blocks.1.attn2conv.bn2.bias', 'layers.3.blocks.1.attn2conv.bn2.running_mean', 'layers.3.blocks.1.attn2conv.bn2.running_var', 'layers.3.blocks.1.attn2conv.bn2.num_batches_tracked', 'layers.3.blocks.1.mlp.fc1.weight', 'layers.3.blocks.1.mlp.fc1.bias', 'layers.3.blocks.1.mlp.fc2.weight', 'layers.3.blocks.1.mlp.fc2.bias', 'layers.3.blocks.1.bn.weight', 'layers.3.blocks.1.bn.bias', 'layers.3.blocks.1.bn.running_mean', 'layers.3.blocks.1.bn.running_var', 'layers.3.blocks.1.bn.num_batches_tracked', 'norm.weight', 'norm.bias', 'head.weight', 'head.bias'])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a['model'].keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "caring-portugal",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'mmdet'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-7-cfa28b2f5978>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m     12\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mmmcv\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mutils\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mget_git_hash\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     13\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 14\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mmmdet\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0m__version__\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     15\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mmmdet\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapis\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mset_random_seed\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtrain_detector\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     16\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mmmdet\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdatasets\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mbuild_dataset\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'mmdet'"
     ]
    }
   ],
   "source": [
    "import argparse\n",
    "import copy\n",
    "import os\n",
    "import os.path as osp\n",
    "import time\n",
    "import warnings\n",
    "\n",
    "import mmcv\n",
    "import torch\n",
    "from mmcv import Config, DictAction\n",
    "from mmcv.runner import get_dist_info, init_dist\n",
    "from mmcv.utils import get_git_hash\n",
    "\n",
    "from mmdet import __version__\n",
    "from mmdet.apis import set_random_seed, train_detector\n",
    "from mmdet.datasets import build_dataset\n",
    "from mmdet.models import build_detector\n",
    "from mmdet.utils import collect_env, get_root_logger\n",
    "\n",
    "\n",
    "def parse_args():\n",
    "    parser = argparse.ArgumentParser(description='Train a detector')\n",
    "    parser.add_argument('config', help='train config file path')\n",
    "    parser.add_argument('--work-dir', help='the dir to save logs and models')\n",
    "    parser.add_argument(\n",
    "        '--resume-from', help='the checkpoint file to resume from')\n",
    "    parser.add_argument(\n",
    "        '--no-validate',\n",
    "        action='store_true',\n",
    "        help='whether not to evaluate the checkpoint during training')\n",
    "    group_gpus = parser.add_mutually_exclusive_group()\n",
    "    group_gpus.add_argument(\n",
    "        '--gpus',\n",
    "        type=int,\n",
    "        help='number of gpus to use '\n",
    "        '(only applicable to non-distributed training)')\n",
    "    group_gpus.add_argument(\n",
    "        '--gpu-ids',\n",
    "        type=int,\n",
    "        nargs='+',\n",
    "        help='ids of gpus to use '\n",
    "        '(only applicable to non-distributed training)')\n",
    "    parser.add_argument('--seed', type=int, default=None, help='random seed')\n",
    "    parser.add_argument(\n",
    "        '--deterministic',\n",
    "        action='store_true',\n",
    "        help='whether to set deterministic options for CUDNN backend.')\n",
    "    parser.add_argument(\n",
    "        '--options',\n",
    "        nargs='+',\n",
    "        action=DictAction,\n",
    "        help='override some settings in the used config, the key-value pair '\n",
    "        'in xxx=yyy format will be merged into config file (deprecate), '\n",
    "        'change to --cfg-options instead.')\n",
    "    parser.add_argument(\n",
    "        '--cfg-options',\n",
    "        nargs='+',\n",
    "        action=DictAction,\n",
    "        help='override some settings in the used config, the key-value pair '\n",
    "        'in xxx=yyy format will be merged into config file. If the value to '\n",
    "        'be overwritten is a list, it should be like key=\"[a,b]\" or key=a,b '\n",
    "        'It also allows nested list/tuple values, e.g. key=\"[(a,b),(c,d)]\" '\n",
    "        'Note that the quotation marks are necessary and that no white space '\n",
    "        'is allowed.')\n",
    "    parser.add_argument(\n",
    "        '--launcher',\n",
    "        choices=['none', 'pytorch', 'slurm', 'mpi'],\n",
    "        default='none',\n",
    "        help='job launcher')\n",
    "    parser.add_argument('--local_rank', type=int, default=0)\n",
    "    args = parser.parse_args()\n",
    "    if 'LOCAL_RANK' not in os.environ:\n",
    "        os.environ['LOCAL_RANK'] = str(args.local_rank)\n",
    "\n",
    "    if args.options and args.cfg_options:\n",
    "        raise ValueError(\n",
    "            '--options and --cfg-options cannot be both '\n",
    "            'specified, --options is deprecated in favor of --cfg-options')\n",
    "    if args.options:\n",
    "        warnings.warn('--options is deprecated in favor of --cfg-options')\n",
    "        args.cfg_options = args.options\n",
    "\n",
    "    return args"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "impossible-physics",
   "metadata": {},
   "outputs": [],
   "source": [
    "args = parse_args()\n",
    "args.config='configs/swin/cascade_mask_rcnn_swin_tiny_patch4_window7_mstrain_480-800_giou_4conv1f_adamw_3x_coco.py'\n",
    "cfg = Config.fromfile(args.config)\n",
    "model = build_detector(\n",
    "    cfg.model,\n",
    "    train_cfg=cfg.get('train_cfg'),\n",
    "    test_cfg=cfg.get('test_cfg'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "surrounded-thanksgiving",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "detr_fzj",
   "language": "python",
   "name": "detr_fzj"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
